<template>
  <el-aside width="220px"  >
    <el-row class="tac" >
      <el-col background-color="#545c64">
        <el-menu
          default-active="0"
          class="el-menu-vertical-demo"
          
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
        >
          <template v-for="(item, index) in contents">
            <el-menu-item
              :key="index"
              :index="index + ''"
              v-if="item.children == ''"
              @click="toPath(item.path)"
            >
              <i :class="item.icon"></i>
              <span slot="title">{{ item.nameZh }}</span>
            </el-menu-item>

            <el-submenu :index="index + ''" :key="index" v-else>
              <template slot="title">
                <i :class="item.icon"></i>
                <span>{{ item.nameZh }}</span>
              </template>
              <el-menu-item-group>
                <template v-for="(item1, index1) in item.children">
                  <el-menu-item
                    :index="index + '-' + index1"
                    :key="index1"
                    @click="toPath(item1.path)"
                  >
                    <i :class="item1.icon"></i>
                    {{ item1.nameZh }}
                  </el-menu-item>
                </template>
              </el-menu-item-group>
            </el-submenu>
          </template>
        </el-menu>
      </el-col>
    </el-row>
  </el-aside>
</template>
<script>
export default {
  data() {
    return {
      contents: [],
      username: this.$store.state.user.username,
    };
  },
  mounted() {
    this.show();
  },
  methods: {
    show() {
      let that = this;
      let params = {
        username: that.username,
      };

      that
        .$axios({
          method: "post",
          params: params,
          url: "/userrole/findAllMenu",
        })
        .then(function (res) {
          that.contents = res.data.result;
        })
        .catch(function (error) {
          console.log(error);
        });
    },
    toPath(path) {
      this.$router.push({ path });
    },
  },
};
</script>

<style scoped>
.el-row {
  height: 100%;
  background-color:#545c64
}

.el-menu {
  border-right: none;
  
  background-color:#545c64
}
.el-aside {
  border-right: 1px solid #f5f1f1;
}
</style>
